package com.baidu.fd1931springbootdemo.controller;

import com.baidu.fd1931springbootdemo.bean.ListOfPlayers;
import com.baidu.fd1931springbootdemo.service.ListOfPlayersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ListOfPlayersController {
    @Autowired
    private ListOfPlayersService listOfPlayersService;

    @RequestMapping("/upData")
    public String toUpData(ListOfPlayers listOfPlayers){
        System.out.println("listOfPlayers = " + listOfPlayers);
        if (null == listOfPlayers.getId()) {
            //新增
            listOfPlayersService.incReaseService(listOfPlayers);
        }else {
            //修改
            listOfPlayersService.upDataService(listOfPlayers);
        }
        return "table/editable_table";
    }

    @RequestMapping("/delete")
    public String toDelete(int id) {
     listOfPlayersService.deleteService(id);
        return "table/editable_table";
    }

}
